home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / slib / tk / demos / mkRadio.tcl < prev    next >
Text File  |  1994-09-20  |  3KB  |  59 lines

  1. # mkRadio w
  2. #
  3. # Create a top-level window that displays a bunch of radio buttons.
  4. #
  5. # Arguments:
  6. #    w -    Name to use for new top-level window.
  7.  
  8. proc mkRadio {{w .r1}} {
  9.     catch {destroy $w}
  10.     toplevel $w
  11.     dpos $w
  12.     wm title $w "Radiobutton Demonstration"
  13.     wm iconname $w "Radiobuttons"
  14.     message $w.msg -font -Adobe-times-medium-r-normal--*-180* -aspect 300 \
  15.         -text "Two groups of radiobuttons are displayed below.  If you click on a button then the button will become selected exclusively among all the buttons in its group.  A Tcl variable is associated with each group to indicate which of the group's buttons is selected.  Click the \"See Variables\" button to see the current values of the variables.  Click the \"OK\" button when you've seen enough."
  16.     frame $w.frame -borderwidth 10
  17.     frame $w.frame2
  18.     pack $w.msg -side top
  19.     pack $w.msg -side top
  20.     pack $w.frame -side top -fill x -pady 10
  21.     pack $w.frame2 -side bottom -fill x
  22.  
  23.     frame $w.frame.left
  24.     frame $w.frame.right
  25.     pack $w.frame.left $w.frame.right -side left -expand yes
  26.  
  27.     radiobutton $w.frame.left.b1 -text "Point Size 10" -variable size \
  28.         -relief flat -value 10
  29.     radiobutton $w.frame.left.b2 -text "Point Size 12" -variable size \
  30.         -relief flat -value 12
  31.     radiobutton $w.frame.left.b3 -text "Point Size 18" -variable size \
  32.         -relief flat -value 18
  33.     radiobutton $w.frame.left.b4 -text "Point Size 24" -variable size \
  34.         -relief flat -value 24
  35.     pack $w.frame.left.b1 $w.frame.left.b2 $w.frame.left.b3 $w.frame.left.b4 \
  36.         -side top -pady 2 -anchor w
  37.  
  38.     radiobutton $w.frame.right.b1 -text "Red" -variable color \
  39.         -relief flat -value red
  40.     radiobutton $w.frame.right.b2 -text "Green" -variable color \
  41.         -relief flat -value green
  42.     radiobutton $w.frame.right.b3 -text "Blue" -variable color \
  43.         -relief flat -value blue
  44.     radiobutton $w.frame.right.b4 -text "Yellow" -variable color \
  45.         -relief flat -value yellow
  46.     radiobutton $w.frame.right.b5 -text "Orange" -variable color \
  47.         -relief flat -value orange
  48.     radiobutton $w.frame.right.b6 -text "Purple" -variable color \
  49.         -relief flat -value purple
  50.     pack $w.frame.right.b1 $w.frame.right.b2 $w.frame.right.b3 \
  51.         $w.frame.right.b4 $w.frame.right.b5 $w.frame.right.b6 \
  52.         -side top -pady 2 -anchor w
  53.  
  54.     button $w.frame2.ok -text OK -command "destroy $w" -width 12
  55.     button $w.frame2.vars -text "See Variables" -width 12\
  56.         -command "showVars $w.dialog size color"
  57.     pack $w.frame2.ok $w.frame2.vars -side left -expand yes -fill x
  58. }
  59.